/**
  ******************************************************************************
  * @author     Chris
  * @since      2023/9/29 22:38
  *
  * @file       hd_led.c
  * @brief      LED Hardware Driver.
  *
  * @note       This file contains the hardware driver for the LED.
  *
  * @warning    The current flowing through the LED cannot exceed 25 mA. It's
  *             better to add a register with LED.
  ******************************************************************************
  * Change Logs:
  *   Date           Author       Notes
  *   2023-09-29     Chris        the first version
  *
  ******************************************************************************
  */

#include <delay.h>
#include "stm32g4xx_ll_bus.h"
#include "stm32g4xx_ll_gpio.h"
#include "pd_h_gpio.h"



/** region Declaration and Definition Region */


/** region Variables and Constants Region */

/** endregion Variables and Constants Region */


/** region Function Declaration Region */

/** endregion Function Declaration Region */


/** endregion Declaration and Definition Region */



/** region Public Definition Region */
/**
 * @brief   LED（Light Emitting Diode，发光二极管）初始化
 * @note    GPIO 配置为上拉输出模式即可。
 * @param   无
 * @retval  无
 */
void HD_LED_Init(void) {
    PD_H_GPIO_LEDInit();
}

/**
 * @brief   LED（Light Emitting Diode，发光二极管）点亮
 *
 * @note    GPIO 配置为上拉输出模式即可。
 * @param   无
 * @retval  无
 */
void HD_LED_On(void) {
    PD_H_GPIO_WriteBit(GPIOB, LL_GPIO_PIN_4, RESET);
}

/**
 * @brief   LED（Light Emitting Diode，发光二极管）关闭
 *
 * @note    GPIO 配置为上拉输出模式即可。
 * @param   无
 * @retval  无
 */
void HD_LED_Off(void) {
    PD_H_GPIO_WriteBit(GPIOB, LL_GPIO_PIN_4, SET);
}

/**
 * @brief   LED（Light Emitting Diode，发光二极管）翻转
 *
 * @note    通过寄存器的方式实现 GPIO 口的翻转
 * @param   无
 * @retval  无
 */
void HD_LED_Turn(void) {
    PD_H_GPIO_TurnBit(GPIOB, LL_GPIO_PIN_4);
}

/**
 * @brief   LED（Light Emitting Diode，发光二极管）流水灯点亮
 *
 * @note    使用 PA0、PA2、PA4 三个 LED 组成流水灯
 * @param   无
 * @retval  无
 */
void HD_LED_WaterLight(void) {
    PD_H_GPIO_WriteBit(GPIOA, LL_GPIO_PIN_0, SET);
    PD_H_GPIO_WriteBit(GPIOA, LL_GPIO_PIN_4, RESET);
    delay_ms(300);
    PD_H_GPIO_WriteBit(GPIOA, LL_GPIO_PIN_0, RESET);
    PD_H_GPIO_WriteBit(GPIOA, LL_GPIO_PIN_2, SET);
    delay_ms(300);
    PD_H_GPIO_WriteBit(GPIOA, LL_GPIO_PIN_2, RESET);
    PD_H_GPIO_WriteBit(GPIOA, LL_GPIO_PIN_4, SET);
    delay_ms(300);
}



/** endregion public function region */



/** region private function region */

/** endregion private function region */
